home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_7_2.arc / WINDEV2.ARC / WINAUX.C < prev    next >
Text File  |  1988-12-04  |  2KB  |  104 lines

  1. /*
  2.  * Winaux main module
  3.  *
  4.  * Written by Bill Hall
  5.  * 3665  Benton Street, #66
  6.  * Santa Clara, CA 95051
  7.  *
  8.  * See Winaux.doc for usage information
  9.  *
  10.  */
  11.  
  12. #define NOCOMM
  13. #include <windows.h>
  14. #include <ttycls.h>
  15.  
  16. #define EXTERN
  17. #include "winaux.h"
  18.  
  19. /* entry point for windows */
  20. int FAR PASCAL WinMain(hInstance, hPrevInstance, lpszCmdLine, cmdShow)
  21. HANDLE hInstance, hPrevInstance;
  22. LPSTR lpszCmdLine;
  23. int cmdShow;
  24. {
  25.  
  26.     MSG msg;
  27.  
  28.     /* initialize program */
  29.     if (!InitProgram(hInstance,hPrevInstance, lpszCmdLine, cmdShow))
  30.       /* if we fail, then exit */
  31.     return FALSE;
  32.  
  33.     /* otherwise read messages until program is terminated by user */
  34.     while (GetMessage((LPMSG)&msg,NULL,0,0)) {
  35.     TranslateMessage((LPMSG)&msg);
  36.     DispatchMessage((LPMSG)&msg);
  37.     }
  38.     return msg.wParam;
  39. }
  40.  
  41. /* main window procedure */
  42. long FAR PASCAL MainWndProc(hWnd,message,wParam,lParam)
  43. HWND hWnd;
  44. unsigned message;
  45. WORD wParam;
  46. LONG lParam;
  47. {
  48.  
  49.     PAINTSTRUCT ps;
  50.     
  51.     switch(message) {
  52.  
  53.       /* adjust position of text display if window is resized */
  54.     case WM_SIZE:
  55.         AdjustHeight(LOWORD(lParam), HIWORD(lParam));
  56.         break;
  57.  
  58.       /* menu commands */
  59.     case WM_COMMAND:
  60.         WndCommand(hWnd, wParam);
  61.         break;
  62.  
  63.       /* display string from remote program */
  64.     case WM_USER:
  65.         DispatchString(hWnd, wParam, lParam);
  66.         break;
  67.  
  68.       /* initialize some things when window is created */
  69.     case WM_CREATE:
  70.         WndCreate(hWnd,lParam);
  71.         break;
  72.  
  73.       /* quit */
  74.     case WM_DESTROY:
  75.         PostQuitMessage(0);
  76.         break;
  77.  
  78.       /* set window handle to null in win.ini when closing application */
  79.     case WM_CLOSE:
  80.         SetWinIni(NULL);
  81.         DestroyWindow(hWnd);
  82.         break;
  83.  
  84.       /* if closing Windows, set window handle to null in win.ini */
  85.     case WM_ENDSESSION:
  86.         if (wParam)
  87.         SetWinIni(NULL);
  88.         break;
  89.  
  90.       /* refresh the window */
  91.     case WM_PAINT:
  92.         BeginPaint(hWnd, (LPPAINTSTRUCT)&ps);
  93.         MainWndPaint(hWnd, (LPPAINTSTRUCT)&ps);
  94.         EndPaint(hWnd, (LPPAINTSTRUCT)&ps);
  95.         break;
  96.  
  97.       /* all other messages are handled by windows */
  98.     default:
  99.         return ((long)DefWindowProc(hWnd,message,wParam,lParam));
  100.         break;
  101.     }
  102.     return(0L);
  103. }
  104.